"""
@Time ： 2022/10/31 10:24
@Auth ： 陈杰 200320501042
@E-mail : 1612845322@qq.com
"""
from abc import ABCMeta, abstractmethod


class Shape(object):  # 形状为抽象类
    __metaclass__ = ABCMeta

    def __init__(self):
        self._color = "black"  # 默认颜色为黑色

        @abstractmethod
        def draw(self): pass


class Circle(Shape):  # 圆类包括圆心坐标和半径
    def __init__(self, x, y, r):
        self.__x = x
        self.__y = y
        self.__r = r

    def draw(self):
        print("Draw Circle:(%d,%d,%d)" % (self.__x, self.__y, self.__r))


class Line(Shape):  # 线类包括起点与终点坐标
    def __init__(self, x1, y1, x2, y2):
        self.__x1 = x1
        self.__y1 = y1
        self.__x2 = x2
        self.__y2 = y2

    def draw(self):
        print("Draw Line:(%d,%d,%d,%d)" % (self.__x1, self.__y1, self.__x2, self.__y2))


if __name__ == "__main__":
    c1 = Circle(10, 10, 5)
    c1.draw()
    line1 = Line(10, 10, 20, 20)
    line1.draw()
    print("-" * 60)
    print("列表方式实现：")
    list = []
    c2 = Circle(20, 20, 10)
    line2 = Line(20, 20, 30, 30)
    list.append(c2)
    list.append(line2)
    for i in range(len(list)):
        list[i].draw()
